#include <iostream>
using namespace std;

int main(void)
{
	int A[15]={-1,0,2,-2,3,4,-5,-6,1,2,3,4,5,6,7};
	int sum=0;
	int max=A[0];
	int beg,end;
	int k;

	for(int j=0;j<15;j++)
	{
		if(sum>=0)
		{
			sum+=A[j];

			if(A[j]>=0)
			    end=j;
			else
				end=k;
				
		}
		else
		{
			sum=A[j];
			beg=j;
		}
		if(sum>=max)
			max=sum;
	 k=end;
	}

	if(beg>=end)
		beg=end;
	cout<<"max"<<max<<endl;
	cout<<"beg"<<beg<<"end"<<end;

	cout<<endl;

	return 0;
}